home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
Newsletters
/
GEnieUnixNews
/
unxnl-08.91
< prev
next >
Wrap
Text File
|
1992-12-27
|
24KB
|
597 lines
_ __ _ _ __ _ __
// / //| // || \\| N E W S
//_/ // |// || |\\ Vol 2, Issue 4 - August 1991
R o u n d T a b l e
Items of interest to participants of the GEnie Unix RoundTable
The RoundTable SysOps are:
Dave Weinstein......OLORIN Brian Riley.........DELPHI
Gary Smith..........GARS Chris North-Keys....HARP
Rick Mobley.........LRARK All Unix SysOps.....UNIXSYSOPS$
We strongly encourage you to contact any or all of us if you have -ANY-
comments or suggestions. This is -YOUR- RoundTable. We are here to make
your participation as pleasant and beneficial as possible.
ED: editor notes - Chocolate Friendly Interface:
-- editorial note from Dave Weinstein
Is there something about the Unix RoundTable that isn't quite right?
Or is Unix just driving you to distraction...
While we hope that you'd write us at UNIXSYSOPS$ with any problems, comments
or suggestions, there is also another alternative...
Unix RT Sysop Dave Weinstein will be participating in the Chocolate Pie
Throw at this year's FidoCon in Denver... So throw a pie for a good cause,
and fondly remember all the wonderful little things about Unix that were
so much fun to encounter for the first time!
--
Using the Korn Shell (ksh) Using KSH made a LOT easier. Gary (GARS)
--------------------------
Ron Heiby, moderator of mod.os.unix dusted off some old notes on using
the Korn Shell that have not aged a bit. ksh is gaining in popularity
so this piece is a definite keeper. Gary (GARS)
If my records are complete, I posted the this article in December of
1986, while working for AT&T. Then, with modifications in December of
1987, while working for Motorola. Since then, Ksh-88 has been
released and I've seen quite a few articles asking to do lots of stuff
with the prompt string. So, here it is again, modified for Ksh-88 a
bit and enhanced in some other minor ways. If you are still using an
older version of Ksh, UPGRADE! Enjoy!
A while ago [from the perspective of someone writing in December of
1986], there were several messages posted to Usenet which showed ways
to include various information into a Korn Shell PS1 prompt. I
thought that a number of these were real clever and incorporated them
into my own environment.
Now that Motorola Microcomputer Division [now the Motorola Computer
Group] is selling the Korn Shell for our Delta Series of 68020-based
systems, I thought I'd share this generally.
Relatively little here is my own invention, but I can no longer say
who had every idea. I did put a lot of work into integrating
everything together so that it would all work in a coordinated
fashion. The time stamp stuff is from Korn. The "autoload" stuff
[originally used] for functions (pshd, popd, etc.) as well as the
original versions of those functions is from a Usenet article by Avi
E. Gross in 10/84. [This has since been absorbed in slightly
different form into standard Ksh-88.] I have made some readability
and efficiency enhancements to the originals, as well as merging them
into the rest of the stuff here. I pulled out the large blocks of
comments in Avi's original to improve the performance in my running
copy and keep the original intact elsewhere so I can figure out what's
going on. As to the prompt-resetting code, I know there were at least
three different people (plus me) who contributed to what is merged
together here, but I lost the original Usenet articles. Thanks,
whoever you are.
I've tried to put this is into a form that you can easily install into
your own environment. I mostly did it to see if I could. Since then,
it has proved useful enough for me to keep it as my normal
environment.
One could easily turn up one's nose at all this, if one really likes the "$ "
prompt, as this is about as far from that as you can get. The normal prompt
when logged in and in your home directory is: host: hh:mm:ss [~]
nn>
After "cd /usr/src/cmd/vi", it is: host: hh:mm:ss [src/cmd/vi]
nn>
After "pshd /usr", it is: host: hh:mm:ss 1: [/usr]
nn>
After "popd", it is back to: host: hh:mm:ss [src/cmd/vi]
nn>
After invoking a sub-shell (ksh): host: hh:mm:ss [src/cmd/vi]
nn>>
The "host" is the output of the "uname" command. I added the host
name to the prompt to make it more obvious to whom I was "talking" in
the face of "cu" and "rlogin" and windowing terminals. The "nn" is
the ksh history number. hh:mm:ss is the time. As you can see, up to
the last three directories in your current directory are included. If
you are in a subdirectory of your home directory, your home directory
path counts as a single directory and is represented with a tilde (~).
If you are using Shell Layers (shl), the layer name "foo" or number
"(n)" is displayed as part of the prompt, too. If the uid of the user
is 0 (root), then a pound sign (#) is used instead of a greater-than
(>) to indicate nesting of sub-shells. The prompt was split into two
lines because the escape sequences to highlight a non-zero return code
get counted as printable characters and so fewer characters from the
command you are entering are visible in the line.
Good luck trying to change any of it without breaking something else.
I am currently running ksh "Version 11/16/88e".
Even if you don't use this, it makes an interesting exercise to figure
out how everything works. After doing so, you'll have a very good
understanding of ksh programming.
Ron.
--------- This goes in your .profile --------
# environment for fancy prompt
export PSSHL PS1="!$ " FPATH=~/ksh
-------- This goes in your $ENV file ---------
# All this good stuff needed for interactive shells only.
# Guard it with appropriate tests for better effeciency of startup.
# Here's a good example of this:
# case "$-" in
# *c*) # Stuff for -c, command line shells goes here.
# :
# ;;
# *) # Stuff for for non -c, (interactive) shells.
# :
# ;;
# esac
#
# Set prompt string portion for Shell Layers layer.
TTY=$(tty)
if [ "$TTY" != "${TTY#*sxt}" -a "${SHDEPTH:-}" = ">" ]
then
export PSSHL=$PS1
fi
unset TTY
#
# Set System name string for fancy prompt
UNAME=$(uname)
#
# Set standout strings for fancy prompt
: ${SMSO:=$(tput smso)} ${RMSO:=$(tput rmso)}
#
# Set up for time stamping
typeset -RZ2 _x1 _x2 _x3
let SECONDS=$(date '+3600*%H+60*%M+%S')
TIME='"${_d[(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)]}$_x1:$_x2:$_x3"'
#
# Define the replacement for the "cd" builtin
function ch {
if cd ${*:-''}
then
resetps1
else
return 1
fi
}
alias cd=ch # make it easy to use
function resetps1 {
typeset _dir=$PWD
typeset _dirt=${_dir#$HOME} # directory tail
if [ "${_dirt}" != "${_dir}" ]
then
_dir="~${_dirt}"
fi
typeset front=${_dir%/*/*/*}
: ${front:=x}
case ${pushlevel:-0} in
0) PS1="${UNAME}: ${TIME} ${PSSHL:-}${SMSO:-}\${?#0}${RMSO:-}[${_dir#$front/}]
!$SHDEPTH ";;
*) PS1="${UNAME}: ${TIME} $pushlevel: ${PSSHL:-}${SMSO:-}\${?#0}${RMSO:-}[${_dir#$front/}]
!$SHDEPTH ";;
esac
}
# Functions related to push and pop routines
alias dirs='echo "\t0: $PWD"' \
popd='echo "You have never pushed any levels.\nYou remain at $PWD."'
#
# Check for uid 0 (root)
id=$(id)
id=${id#uid=}
id=${id%%\(*}
if [ id -eq 0 ]
then
export SHDEPTH=${SHDEPTH:-}'#'
else
export SHDEPTH=${SHDEPTH:-}'>'
fi
# Set special colors
case $TERM in
mskermc)
case $id in
0) color=37 ;;
501) color=31 ;;
*) color=35 ;;
esac
SMSO="[41;33m" RMSO="[44;${color}m[1m"
unset color
;;
tm229|tm229g)
case $id in
0) color=33 ;;
501) color=37 ;;
*) color=35 ;;
esac
SMSO="[41;33m" RMSO="[40;${color}m[1m"
unset color
;;
*)
;;
esac
unset id
resetps1
-------- This is ~/ksh/pshd, linked to ~/ksh/pshpwd and ~/ksh/poppwd ---------
unalias popd dirs
integer pushlevel=0
function pshd
{
dirsave[pushlevel]="$PWD" # save the name of the current dir
promptsave[pushlevel]="$PS1" # save the current prompt
if [ pushlevel = 0 ]
then
pushprompt="$PS1"
fi
ch ${1:-$HOME} 2> /dev/null
case $? in
0) # "cd" succeeded.
let pushlevel=pushlevel+1
pwd # show the current directory
: ${2:+`ls -Fx $3 $4 $5 $6 $7 $8 $9 >/dev/tty`}
resetps1
;;
*) # "cd" failed
print "Can't change to $1, aborting"
return 1
;;
esac
} # END of pshd
function popd
{
integer levels=${1:-1}
if (( pushlevel-levels>=0 ))
then
let pushlevel=pushlevel-levels
else
print "Can't pop that many levels. Your choices were:"
dirs
print "You are being returned to your original level"
let pushlevel=0
fi
ch ${dirsave[$pushlevel]}
pwd # show the user where they are.
: ${2:+`ls -Fx $3 $4 $5 $6 $7 $8 $9 >/dev/tty`}
PS1="${promptsave[$pushlevel]}"
}
function dirs
{
integer level=$pushlevel
integer lowest=$level-${1:-$level}
if [ lowest -lt 0 ]
then
lowest=0
fi
print " $level: $PWD"
while [ level -gt lowest ]
do
let level=level-1
print " $level: ${dirsave[$level]}"
done
unset level lowest
}
function pshpwd
{
print $PWD "${@:-}" >~/.current-pwd
}
function poppwd
{
print $(<~/.current-pwd)
}
---- start of pshd family documentation ----
# In brief, this routine is called in the form of:
# . ~/ksh/psh-pop.ksh name arg1 arg2 arg3 ...
# and has to do the following:
# - Unalias all five related alias names.
# - Declare all five function bodies using those names.
# - Run the function that invoked this file, using the provided
# arguments.
# The first time one of these aliases is used, it needs to be "loaded". From
# then on, each one represents a loaded function, and runs smoothly. The
# advantages are that your .env is about a hundred lines smaller, and these
# functions are only defined when used.
# The first three routines are used to maintain and examine a directory stack
# of traversals through the file system. They are:
# pshd [directory] [ls-indicator] [ls-arg] [ls-arg] [ls-arg]
# popd [levels] [ls-indicator] [ls-arg] [ls-arg] [ls-arg]
# dirs [levels]
# These are different than other versions of pshd that have been posted to
# the net. Both pshd and popd have an optional first argument that tells
# which directory to go to, or how many levels to backtrack. If a second
# argument is specified (any string will do) then an "ls -C" is done after
# the action is completed. Any additional arguments are passed to ls. For
# example, "pshd /usr/spool/uucp l -l -a -t" will change the directory to
# /usr/spool/uucp and then do an "ls -C -l -a -t" to show full descriptions
# of all files in that directory in the orer that they were last changed.
# The "-C" argument is used to force our version of ls to columnate the
# output (even if it is going into a pipeline).
# The next two routines are used to share information about the current
# directory # between two windows on a DMD/BLIT or just to save the value
# for later. Only one value is currently supported. They are:
# pshpwd [additional text]
# poppwd
# Poppwd is often used in constructs like "cp *.c `poppwd`"
----------------------------------- end ---------------------------
--
Ron Heiby mcdchg!heiby Moderator: mod.newprod & mod.os.unix
--
Ron Heiby, heiby@chg.mcd.mot.com Moderator: comp.newprod
"Wrong is wrong, even when it helps you." Popeye
--
CHANGING GEARS: Migrating from ms-dos to *nix
--------------
article from Rick Mobley (LRARK)
FROM DOS TO UNIX
By Ricky Mobley, LRARK
For those that wish to enter the exciting world of UNIX, sometimes refered to
as *NIX to cover XENIX and other derivatives, you will find that some of the
commands are very similar. You may even wonder which came first, the chicken
or the egg. UNIX dates back to the mid 60's, DOS can be thought of as a subset
of UNIX since it became popular in the early 70's. Some commands that are
similar would be 'type' which came from 'cat', short for concatanate, format
which still exists, 'dir' which is replaced by 'ls' and many others.
The amazing and sometimes the part which tends to scare off the weak at heart
is the fact that "*NIX is a bottomless pit". That statement is true because of
the large number of manuals that come with a system. Many times a command will
also have the statement "see also" which will more than likely send you off to
another book. Before you know it, you have 5 or 6 manuals open and may still
not fully understand the command you are working with. Thats where the wizards
come in. It is sometimes best to ask someone that has been using *NIX for a
while to get a Reader's Digest version without going fully into the manuals.
You must be careful with this approach as you might get the dreadful 'RTFM'
reply on the simple ones. I'll leave that one for you to figure out.
I have been running *NIX for a long time, and since I left DOS, I have yet to
find one application that I couldn't mimic given the many many utilities that
*NIX comes with. Last count was somewhere around 200. Hows that for a rich
operating system?
In order for you to appreciate the power of this O/S you will have to install
it and use it for a while. There are several good manuals available to get you
started, and of course, there is always the RT on Genie that is filled with
knowledgable users of *NIX. Join in the fun and begin to tap the deep dark
secrets of *NIX. I know you will enjoy it.
Next time, I will go into more details of the O/S and what it has to offer the
first time user.
rick@lrark
--
MACAWK : Sub: awk, nawk, gawk, pcawk, macawk
------
humorware from Mike Nolan (M.NOLAN)
In the beginning, there was 'awk', written by the 3 authors whose initials
make up the name. And AT&T looked at awk, and decided it was of no
consequence, which was good as it was distributed for free.
And then it was said, "But awk needs improvement", and, yea, it came to
pass that there was a new awk, or nawk. And AT&T looked at nawk and
decided it was good, which was bad because then it was bundled.
And it came to pass in the halls of MIT that Richard Stallman said,
"Let programmers go forth and multiply, and let the fruits of their
labors be as free as the air, and let there be a new kernel, conceived
in liberty and dedicated to the proposition that all modifications are
charged for to support the FSF" (oops, sorry, wrong text.)
But it came to pass that there was a GNU day, and GNU software began
to arise like weeds in the vineyard, with an insidious copyleft to
make the source code a part of all distributions. And thus was gawk,
a GNU version of awk, as opposed to the new version of awk, was born.
And the God of programmers looked down upon these awk-ward days, and
declared that the three versions should be only partially compatible,
in keeping with the fabled towers of Babylon.
And then the God of programmers declared, go forth and multiply, which
confused everyone, because forth had not yet been ported. But there
arose a multitudes of awk-like programs, such as pcawk and macawk,
and to this day this awk-full multitude does continue to propogate,
but usually without support.
I hope this clarifies things.
Michael Nolan
--
Op-Ed: Where Unix is going...
--------------------------
article from Dave Weinstein (OLORIN)
A few years back, the Unix community was buzzing with rumors and
speculation over the announcement that a number of companies which had
formerly specialized in extremely proprietary systems had formed a
consortium to create an "Open Unix". Against OSF was the Sun/AT&T
alliance, and flames and rampant speculation about what all of this
would mean for the future of Unix systems were the rage.
Well, it's been a few years, and it's hard to remember why the furor
rose. OSF has been mostly silent (although Motif has become a standard of
sorts), and the spectre of a Sun/AT&T monopoly seems to have disappeared
as SPARC based Unix clones arrived on the market from many of the same
forces which flourished in the PC Clone market.
And now a whole new slew of rumors and speculation have arisen over the
falling out between Microsoft and IBM, the ACE Consortium, and the new
and highly touted Apple/IBM/Motorola alliance.
So why does the (primarily) PC infighting of the past month affect
Unix? Far more companies have Unix capable PCs than have dedicated
Unix machines of any stripe. And the decision to use Windows, X, the Mac,
or any number of systems is no longer one of the scale of the problem,
but which system provides the environment which will be productive
quickly. It isn't the technical expertise which wins this war, but the
marketing, and Unix is facing stronger threats now than in recent years.
Early reports of OS/2 2.0 make it a true player in the office environment,
and the cost of comparable Unix systems (as well as resource drain) is
much higher. The Unix vendors can no longer afford to price full blown
implementations at $500-$1200, the high end PCs and PC specific platforms
are pushing hard into the Workstation market...
--
CUSTOMIZING the User Agent :
--------------------------
Brian Riley (DELPHI) continues his excellent 'hands-on' setup of a
Unix system User Agent, using the venerable 3b1 as his model.
Customizing the User Agent (tm)
on the Unix Pc (tm)
by Brian T. Riley
Part 4
Well, here we are again. If you remember last time, we
were having fun with our .profile's. I promised to explain the
rest of mine. Ok, Here we go! :)
-----------------------------------------
#sccs "@(#)install:.profile 1.3"
set -amh -o vi
umask 000
VISUAL=/usr/bin/vi
PCOMM=$HOME/Pcomm
ROGUEOPTS="name=Delphi"
ENV=$HOME/.kshrc
HISTFILE=$HOME/.ksh.hist
HISTSIZE=24
> $HISTFILE
if [ "$L0" != "u" ]
then
exec /usr/bin/ua
fi
-----------------------------------------
The first line should look familiar. It does this;
-a allexport Exports all variables when set.
-m monitor Displays process # for bg jobs.
-h trackall Makes aliases tracked.
-o vi sets vi editing mode for command line.
The rest is as follows;
Umask sets the file creation mode mask. The value after the
command is subtracted from the system default mode value. On the
Unix-pc, without this command, the default mode is 0644. With the
command I get 0755. VISUAL= makes vi the default editor no matter
what the EDITOR= value. This way I can set the EDITOR= variable
to another value for programs that ignore the VISUAL= variable
and still have vi for the rest. PCOMM= tells Pcomm the
communications program where my configuration files are and
ROGUEOPTS= sets default options when I play the game. These are
two examples of how programers can get information into their
programs while giving the user flexibility.
ENV= tells the Korn shell two things, first it says that we are
using an environment file for the bulk of our aliases and
functions and second it tells the shell where it is. By
separating the aliases and functions from our .profile, and since
it is a shell file, it is more readable and we can make changes
without logging off. HISTFILE= and HISTSIZE= tell the shell where
our history file is and how many of the previous commands we want
to be able to recall. The next line is a little lesson in
redirection. It has the effect of emptying my history file every
time I log in.
The last part we covered last time and lets me start without the
User Agent if I put a "u" after my name when I log in. Did you
notice the "$HOME" in some of my variable names? Ksh
automatically expands this to the path of your home directory.
This is available anywhere in the shell, even when you are
changing your current directory. You could do this;
cd $HOME/newdir
Any of you who got them all right, give yourself a pat on
the back but don't pull a muscle doing it! :) The Korn shell has
some other interesting features as well. Say for example you are
using your system at work and you are using a program that was
written by your company for accounting. But today the program
doesn't work, and you want to check it for problems but you don't
know where it is! After all the system has hundreds of commands
and programs. Well, you could ask everyone in the office where it
is, (but you would look kind of stupid) or you could use
"whence", like this;
whence command <ret>
which will tell you the full path to the program. You
could also use the -v option to tell you what type of command or
program it is. These are the possibilities;
Reserved word
Alias
Exported alias
Built-in shell command
Undefined function
Function
Tracked alias
Program
Not found
Well that's all I have for this installment but I would
like you to post suggestions in the BBS for things you
would like to know about and I will do what I can to
answer your questions. Till next time...
Happy trails to you....
Brian T. Riley
Delphi@UnixRt
brian@jerimy.snide.com
--
---------------
REMINDER - This newsletter is being sent to you 'by request'. If you do
not wish to keep receiving it, e-mail a stop notice to GARS. On the other
hand, we would very much appreciate it if you would pass the word that we
do distribute this item near the tenth (10th) of the month of issue to any-
one on GEnie who requests it, and will gladly add any name that is requested
via the same route... e-mail to GARS.
P L E A S E also remember contributions are most welcome. Please e-mail
items and/or suggestions to GARS.
(EOF)
Trademark and Copyright notices:
Unix is a Trademark of UNIX System Laboratories, Inc.; GEnie, LiveWire, and
RoundTable are Trademarks of General Electric Information Services Company;
Xenix and ms-dos are Trademarks of Microsoft Corporation;
The contents of this newsletter are copyright (c) 1991 and may be copied whole
or in part only if original credit is included. The GEnie UNIX RoundTable is
not affiliated with AT&T or UNIX System Laboratories, Inc.